#include <iostream>
using namespace std;

class Solution {
public:
    // 判重代码；
    bool is_first(const vector<int> &num, int last, int pos) {
        for(int i = last+1; i < pos; i++) {
            if(num[i] == num[pos]) {
                return false;
            }
        }
        return true;
    }
    void dfs(const vector<int> &nums, int last, int pos, vector<int> &stack, vector<vector<int>> &anw) {
        if(nums.size() == pos) { return; } //到达末尾，直接返回吧
        // 检查 nums[pos] 是否符合要求
        if((stack.empty() || nums[pos] >= stack.back()) && is_first(nums, last, pos)) {
            stack.push_back(nums[pos]);
            if(stack.size() >= 2) { //大于 2 了，那就放进去吧
                anw.push_back(stack);
            }
            dfs(nums, pos, pos+1, stack, anw); // 继续处理下一个。
            stack.pop_back(); // 将当前放入这个吐出来。
        }
        dfs(nums, last, pos+1, stack, anw);
    }
    vector<vector<int>> findSubsequences(vector<int>& nums) {
        vector<vector<int>> anw;
        vector<int> stack;
        dfs(nums, -1, 0, stack, anw);
        return anw;
    }
};


class Solution1 {
public:
    int maxProduct(vector<int>& nums) {
        int n = nums.size();
        vector<int> f(n+1);
        auto g = f;
        f[0] = g[0] = 1;
        int fmax = INT_MIN;
        for(int i = 1; i <= n; i++)
        {
            int num = nums[i-1];
            f[i] = max(num, max(f[i-1]*num, g[i-1]*num));
            g[i] = min(num, min(f[i-1]*num, g[i-1]*num));
            fmax = max(fmax, f[i]);
        }

        return fmax;
    }
};

class Solution2 {
public:
    string minWindow(string s, string t) {
        unordered_map<char, int> hash1;
        unordered_map<char, int> hash2;
        int kinds = 0;
        for(char ch : t)
        {
            if(hash1[ch] == 0) kinds++;
            hash1[ch]++;
        }

        int begin = -1, len = INT_MAX;
        for(int left = 0, right = 0, count = 0; right < s.size(); right++)
        {
            char in = s[right];
            hash2[in]++;
            if(hash2[in] == hash1[in]) count++;
            while(count == kinds)
            {
                if(right - left + 1 < len)
                {
                    begin = left;
                    len = right - left + 1;
                }

                if(hash2[s[left]]-- == hash1[s[left]]) count--;
                left++;
            }
        }

        if(begin == -1) return "";
        else return s.substr(begin, len);
    }
};

int main() {
    Solution s;
    return 0;
}